package com.example.blog.service;

import com.example.blog.Utils.JWTUtils;
import com.example.blog.mapper.BlogMapper;
import com.example.blog.mapper.UserMapper;
import com.example.blog.model.BlogInfo;
import com.example.blog.model.UserInfo;
import com.example.blog.result.Result;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private BlogMapper blogMapper;
    public UserInfo getUserInfoByName(String userName) {
        return userMapper.selectByUserName(userName);
    }
    public UserInfo getUserInfoById(Integer Id) {
        return userMapper.selectById(Id);
    }

    public UserInfo getAuthorById(@NonNull Integer id) {
       BlogInfo blogInfo = blogMapper.selectById(id);
       Integer userId = blogInfo.getUserId();
        return userMapper.selectById(userId);
    }
}
